package com.huat.spring_boot.service;

import com.huat.spring_boot.mapper.StudentGradeMapper;
import com.huat.spring_boot.pojo.StudentGrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentGradeService {

    @Autowired
    private StudentGradeMapper studentGradeMapper;

    public StudentGrade findById(Long id) {
        return studentGradeMapper.findById(id);
    }

    public List<StudentGrade> findAll() {
        return studentGradeMapper.findAll();
    }

    public void save(StudentGrade studentGrade) {
        if (studentGrade.getId() == null) {
            studentGradeMapper.insert(studentGrade);
        } else {
            studentGradeMapper.update(studentGrade);
        }
    }

    public void delete(Long id) {
        studentGradeMapper.delete(id);
    }
}
